Copyright: Copyright © 1995 Caprock Software
Citation: Copyright © 1995 Caprock Software


 .INI Control

Properties	Methods	Events	Functions

Description

The .INI control provides easy access to the initialization file features of Windows v3.1.  When developing your own applications with Visual Basic v3.0 you can create .ini files or modify the win.ini file in your Windows directory.  No more fooling around with the API commands or messy C strings!

File Name

INI.VBX

Remarks

The .INI control has one custom event.  Any time Windows detects a change in the Windows intialization file, WIN.INI, a message is sent to the .INI control.

The .INI control has a few custom properties that allow you to manipulate .ini files.  The control has no visual appearances during run-time of your applications.  Manipulation of strings are in Visual Basic strings and not C (or null terminated) strings!

Two functions are included with this control to enhance the functionality of intialization file manipulation.  See Functions for more information.

This .INI control was designed for and tested with Visual Basic v3.0 and Windows v3.1.  It was written in Visual C++ v1.51.

Bound Properties

This control is not a bound control.

Distribution Note	When you create and distribute applications that use the .INI control, you should install the file INI.VBX  in the customer's Microsoft Windows\SYSTEM sub directory.  The Setup Wizard included with Visual Basic provides tools to help you write setup programs that install your application correctly.

Copyright


Copyright

This .INI control is shareware.  You can evaluate this control free of charge for 30 days.

If you like it, please pay $12.00.  You can also purchase the source code for $70.00 (this includes your registration fee).

You can register the VBX on Compuserve in the SWREG forum using SWREG ID: 5266.  You can also purchase the source code using SWREG ID: 5267.  Or, send check or money order to:  Caprock Software, 4032 N. Story Rd. #124A, Irving, Texas 75038.

Visual Basic v3.0, Windows v3.1 and Visual C++ v1.51 are copyrights of Microsoft Corp.

Please feel free to send suggestions and comments to Caprock Software at CompuServe: 73474,313 or Internet: sstubbs@iadfw.net.


Properties

All of the properties for this control are listed in the following table.  Properties that apply only to this control, or that require special consideration when used with it, are marked with an asterisk (*).  For documentation of the remaining properties, see the Visual Basic manuals.

*Action	Left
CtlName	Parent
*Default	*Password
*Entry	*Section
*FileName	Tag
Height	*Text
Hwnd	Top
Index	Width

Text is the default value


Methods

All the methods for this control are listed in the following table.  For documentation of the following methods, see the Visual Basic manuals.

Move	ZOrder
Refresh


Events

All of the events for this control are listed in the following table.  Events that apply only to this control, or that require special consideration when used with it, are marked with an asterisk (*).  For documentation of the remaining events, see the Visual Basic manuals.

*WinIniChange

WinIniChange is the default event


Functions

All the functions for this control are listed in the following table.  These functions are included for enhancing the manipulation of initialization files.

FillSection

FillEntry


Action, .INI Control

Description

The method to invoke a .read, write or delete command.  Determines what action to take on the specified initialization file.

Syntax

[form.]InI.Action[ = setting%]

Remarks

The following table lists the Action settings for the .INI Control.

Setting	Description

0	(Default) No Action.  Used as success return code from other settings.

1	Read.  Reads an entry in the initialization file.

2	Write.  Writes or creates a new entry in the initialization file.

3	Delete Section.  Removes a complete section and all of its associated entries.

4	Delete Entry.  Removes an entry under a section.

5	Unencrypted Read.  Reads an encrypted entry in the initialization file.

6	Encrypted Write.  Writes an encrypted entry in the initializationfile.

Settings 5 and 6 are only useful when the Password property is set.

Dataype

Integer (Enumerated)


Default, .INI Control

Description

Specifies the default value for the given Entry if the entry can not be found in the initialization file.

Syntax

[form.]InI.Default[ = text$]

Remarks

The Default property is only used during a read Action.  If the entry is not found, the .INI Control will copy the text from the Default property to the Text property.  The Default property can beempty.

Data Type

String


Entry, .INI Control

Description

Contains the entry whose associated string is to be retrieved from or written to the initialization file.  This string is stored in the Text property.

Syntax

[form.]InI.Entry[ = text$]

Remarks

The Entry property is required for read, write and delete entry Action.

Data Type

String


FileName, .INI Control

Description

The name of the initialization file.  If this property does not contain the full file path,  Windows searches for the file in the Windows directory.

Syntax

[form.]InI.FileName[ = text$]

Remarks

The FileName property is required for every Action.

Data Type

String


Password, .INI Control

Description

Specifies the password that is used for reading and writing encrypted entries in the initialization file.

Syntax

[form.]InI.Password[ = text$]

Remarks

The Password property is required for encrypted read and write Action.

Data Type

String


Section, .INI Control

Description

Specifies the section that contains the Entry in the initialization file.

Syntax

[form.]InI.Section[ = text$]

Remarks

The Section property is required for read, write, delete section and delete entry Action.

Data Type

String


Text, .INI Control

Description

The Text property receives the string from the initialization file or stores in the associated Entry in the initialization file.

Syntax

[form.]InI.Text[ = text$]

Remarks

The Text property is required for the read and write Action.

Data Type

String


WinIniChange Event, .INI Control

Applies To

.INI Control

Description

An application sends this event to all top-level windows after making a change to the Windows intialization file, WIN.INI. This event occurs only if the FileName property is set to win.ini or something else like c:\windows\win.ini.

Syntax

Sub InI_WinIniChange([Index As Integer,] SectionHeader As String)

Remarks

The WinIniChange event uses these arguments:

Argument	Description

Index	Uniquely identifies a control if it is in a control array.

SectionHeader	Contains a string that specifies the name of the section that has changed (the string does not include the square brackets that enclose the section name).

Note	If an .INI control receives a WinIniChange event with the SectionHeader set to empty, your application should check all sections in WIN.INI thatffect your applications.


FillSection Function, .INI Control

Applies To

.INI Control

Description

Fills an array with all the section headers within an initializaiton file.  If an error occurs, the function will return 0.

Syntax

FillSection(file, thearray)

Remarks

The FillSection function has these parts:

Argument	Description

file	Full file specification.

thearray	A one-dimensional string array.  This is where the section headers will be placed.

Note	All parameters are required.  The array must be one dimentional.  The statement will fill the array until no more sections are available in the initialization file or the array's upper boundary is met (which ever comes first).

Example

Paste the following code into the Declarations section of a new form.

Declare Function FillSection Lib "ini.vbx" (ByVal FileName As String, SectionArray() As String) As Integer

Sub Form_Load()

ReDim sec(100) As String

If FillSection("c:\windows\win.ini", sec()) Then

For i = LBound(sec) To UBound(sec)

If Len(sec(i)) Then Debug.Print sec(i)

Next i

End If

End Sub


FillEntry Function, .INI Control

Applies To

.INI Control

Description

Fills an array with all the entries for a section within an initializaiton file.  If an error occurs, the function will return 0.

Syntax

FillSection(file, section, thearray)

Remarks

The FillEntry function has these parts:

Argument	Description

file	Full file specification.

section	String that specifies the section from which to read all entries.

thearray	A one-dimensional string array.  This is where the section headers will be placed.

Note	All parameters are required.  The array must be one dimentional.  The statement will fill the array until no more entries are available in the initialization file or the array's upper boundary is met (which ever comes first).

Example

Paste the following code into the Declarations section of a new form.

Declare Function FillEntry Lib "ini.vbx" (ByVal FileName As String, ByVal SectionHeader As String, EntryArray() As String) As Integer

Sub Form_Load()

ReDim ent(100) As String

If FillEntry("c:\windows\win.ini", "windows", ent()) Then

For i = LBound(ent) To UBound(ent)

If Len(ent(i)) Then Debug.Print ent(i)

Next i

End If

End Sub